package channelHandler

import (
	"gitee.com/fierce_wolf/go-fox-edge-channel-common/channelRestfulNotify"
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/Map"
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/Method"
)

type ManageHandler struct {
}

func (e *ManageHandler) CreateChannel(channelName string, channelParam map[string]interface{}) {
	// 检测：是否输入了通道名称前缀
	if channelName == "" || !Map.Has(channelParam, "deviceKey") {
		return
	}

	// 发出消息
	channelRestfulNotify.CreateChannel(channelName, channelParam)
}

func (e *ManageHandler) CreateDevice(manufacturer, deviceType, channelName, deviceKey string) {
	// 检测：是否输入了厂商、设备类型、设备名称
	if Method.HasEmpty(manufacturer, deviceType, channelName, deviceKey) {
		return
	}

	// 填写通道参数
	deviceParam := make(map[string]interface{})
	deviceParam["deviceKey"] = deviceKey

	// 发出消息
	channelRestfulNotify.CreateDevice(manufacturer, deviceType, channelName, channelName, deviceParam)
}
